<template>
  <a-card :bordered="false">
    <a-spin :spinning="spinning">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper search-box-cuesList" style="margin-bottom:10px">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="8" :md="10" :sm="24">
              <a-form-item label="文章标题">
                <a-input placeholder="请输入文章标题" v-model.trim="queryParam.contentTitle"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="10" :sm="8">
              <a-form-item label="日期">
                <div style="display:flex;">
                  <a-date-picker v-model="startTime" show-time format="YYYY-MM-DD HH:mm:ss" placeholder="开始时间" @change="handleStartOpenChange" />
                  <a-date-picker v-model="endTime" show-time format="YYYY-MM-DD HH:mm:ss" placeholder="结束时间" @change="handleEndOpenChange" />
                </div>
              </a-form-item>
            </a-col>
            <a-col :xl="4" :lg="7" :md="4" :sm="6">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search" title="搜索" shape="circle"></a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px" title="重置" shape="circle"></a-button>
              </span>
            </a-col>

            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <!-- 操作按钮区域 -->
                <!--                <a-button type="primary" icon="download" @click="handleExportXls('用户信息')">导出</a-button>-->
                <a-dropdown v-if="selectedRowKeys.length > 0">
                  <a-menu slot="overlay">
                    <a-menu-item key="1" @click="batchDel">
                      <a-icon type="delete" />删除</a-menu-item>
                  </a-menu>
                </a-dropdown>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>

      <!-- table区域-begin -->
      <div>

        <a-table ref="table" size="middle" rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="ipagination" :loading="loading" @change="handleTableChange">

          <span slot="action" slot-scope="text, record">
            <a @click="handleSet(record)">编辑</a>
          </span>

        </a-table>
      </div>
      <!-- table区域-end -->
      <article-per-edit ref="articlePerEdit" @ok="searchQuery"></article-per-edit>
    </a-spin>
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { httpAction, getAction } from '@/api/manage'
import ArticlePerEdit from './modules/ArticlePerEditModel'

export default {
  name: 'ArticleManager',
  mixins: [JeecgListMixin],
  components: {
    ArticlePerEdit,
  },
  data() {
    return {
      visible: false,
      description: '文章质量管理',
      departList: [],
      roleList: [],
      // 表头
      columns: [
        {
          title: '内容ID',
          align: 'center',
          dataIndex: 'contentNo',
        },
        {
          title: '文章标题',
          align: 'center',
          dataIndex: 'contentTitle',
        },
        {
          title: '质量评分',
          align: 'center',
          dataIndex: 'articleQuality',
          customRender: (t, r, index) => {
            switch (r.articleQuality) {
              case 1:
                return '较差'
              case 2:
                return '中等'
              case 3:
                return '良好'
              case 4:
                return '优秀'
              default:
                return ''
            }
          },
        },
        {
          title: '文章引用',
          align: 'center',
          dataIndex: 'landingType',
          customRender: (t, r, index) => {
            switch (r.landingType) {
              case 1:
                return '未登载'
              case 2:
                return '引力波登载'
              case 3:
                return '纸媒登载'
              case 4:
                return '全媒登载'
              default:
                break
            }
          },
        },
        {
          title: '传播绩效',
          align: 'center',
          dataIndex: 'score',
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime',
        },

        {
          title: '操作',
          align: 'center',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/content/contentTemplate/perforList',
        delete: '/user/usrUserInfo/delete',
        deleteBatch: '/user/usrUserInfo/deleteBatch',
        exportXlsUrl: 'user/usrUserInfo/exportXls',
        importExcelUrl: 'user/usrUserInfo/importExcel',
        shutdown: '/user/usrUserInfo/shutdownRemark',
      },
      startTime: '',
      endTime: '',
      endOpen: false,
      spinning: false,
      showEditModel: false,
    }
  },
  created() {
    this.getDepartList()
  },
  methods: {
    getDepartList: function() {
      var url = '/sys/sysDepart/queryTreeList'
      getAction(url).then(res => {
        if (res.success) {
          this.departList = res.result
        }
      })
    },
    handleSet(record) {
      const that = this
      that.spinning = true
      var url = '/content/contentTemplate/perforDetail'
      getAction(url, { templateId: record.templateId }).then(res => {
        that.spinning = false
        if (res.success) {
          if (res.result.conContentPerformance == null) {
            res.result.conContentPerformance = {
              landingType: 1,
              articleQuality: 0,
              score: 0,
              remark: '',
              templateId: record.templateId,
            }
          }
          that.$refs.articlePerEdit.edit(res.result, record.realName)
        }
      })
    },
    handleStartOpenChange(e, t) {
      this.queryParam.startTime = t
    },
    handleEndOpenChange(e, t) {
      this.queryParam.endTime = t
    },
  },
}
</script>

<style scoped>
</style>


